InĀ [1]:
import sys
import os

src_path = os.path.abspath(os.path.join(os.getcwd(), "..", "src"))
if src_path not in sys.path:
    sys.path.insert(0, src_path)

from plots import plot_plotly, preprocessing_results, plot_plotly_real
InĀ [2]:
local_FedCluLearn = 'results/results_FedCluLearn_2025-02-25_09_52_06.632308.txt'
global_FedCluLearn = 'results/global_model_evaluation_FedCluLearn_2025-02-25_09_52_06.632308.txt'

local_FedCluLearn = 'results/results_FedCluLearn_2025-02-25_10_46_05.736246.txt'
global_FedCluLearn = 'results/global_model_evaluation_FedCluLearn_2025-02-25_10_46_05.736246.txt'

local_FedAvg = 'results/results_FedAvg_2025-02-25_10_41_23.649440.txt'
global_FedAvg = 'results/global_model_evaluation_FedAvg_2025-02-25_10_41_23.649440.txt'

local_FedAtt = 'results/results_FedAtt_2025-02-25_10_46_18.152654.txt'
global_FedAtt = 'results/global_model_evaluation_FedAtt_2025-02-25_10_46_18.152654.txt'

local_FedProx = 'results/results_FedProx_2025-02-25_10_46_26.787383.txt'
global_FedProx = 'results/global_model_evaluation_FedProx_2025-02-25_10_46_26.787383.txt'

local_FedCluLearn_recent = 'results/results_FedCluLearn_2025-02-25_10_54_24.530009.txt'
global_FedCluLearn_recent = 'results/global_model_evaluation_FedCluLearn_2025-02-25_10_54_24.530009.txt'

local_FedCluLearn_Prox_recent = 'results/results_FedCluLearn_Prox_2025-02-25_10_59_22.761987.txt'
global_FedCluLearn_Prox_recent = 'results/global_model_evaluation_FedCluLearn_Prox_2025-02-25_10_59_22.761987.txt'

local_FedCluLearn_Prox = 'results/results_FedCluLearn_Prox_2025-02-25_10_59_52.753193.txt'
global_FedCluLearn_Prox = 'results/global_model_evaluation_FedCluLearn_Prox_2025-02-25_10_59_52.753193.txt'

local_FedCluLearn_percentage = 'results/results_FedCluLearn_2025-02-25_11_11_35.154727.txt'
global_FedCluLearn_percentage = 'results/global_model_evaluation_FedCluLearn_2025-02-25_11_11_35.154727.txt'

local_FedCluLearn_Prox_percentage = 'results/results_FedCluLearn_Prox_2025-02-25_11_11_59.005370.txt'
global_FedCluLearn_Prox_percentage = 'results/global_model_evaluation_FedCluLearn_Prox_2025-02-25_11_11_59.005370.txt'

local_FedCluLearn_percentage_25 = 'results/results_FedCluLearn_percentage_2025-03-03_15_00_50.321053.txt'
global_FedCluLearn_percentage_25 = 'results/global_model_evaluation_FedCluLearn_percentage_2025-03-03_15_00_50.321053.txt'

local_FedCluLearn_Prox_percentage_25 = 'results/results_FedCluLearn_Prox_percentage_2025-03-03_15_01_00.960897.txt'
global_FedCluLearn_Prox_percentage_25 = 'results/global_model_evaluation_FedCluLearn_Prox_percentage_2025-03-03_15_01_00.960897.txt'

local_FedCluLearn_percentage_75 = 'results/results_FedCluLearn_percentage_2025-03-03_15_01_21.724734.txt'
global_FedCluLearn_percentage_75 = 'results/global_model_evaluation_FedCluLearn_percentage_2025-03-03_15_01_21.724734.txt'

local_FedCluLearn_Prox_percentage_75 = 'results/results_FedCluLearn_Prox_percentage_2025-03-03_15_01_32.557997.txt'
global_FedCluLearn_Prox_percentage_75 = 'results/global_model_evaluation_FedCluLearn_Prox_percentage_2025-03-03_15_01_32.557997.txt'
InĀ [3]:
local_filenames = [local_FedCluLearn, local_FedAvg, local_FedAtt, local_FedProx, local_FedCluLearn_Prox]
global_filenames = [global_FedCluLearn, global_FedAvg, global_FedAtt, global_FedProx, global_FedCluLearn_Prox]
InĀ [4]:
mse_column = 'mse'
n_rounds, y = preprocessing_results(filenames=local_filenames, mse_column=mse_column)
plot_plotly(n_rounds, y, title='Avg MSE Local models', y_axis_title=f'{mse_column.upper()} error', y_axis_max=0.3)
InĀ [5]:
for client_id in [0,1,2]:
    n_rounds, y = preprocessing_results(filenames=local_filenames, client_id=client_id, mse_column='mse')
    plot_plotly(n_rounds, y, title=f'MSE Local model Client {client_id}', y_axis_title='MSE error')
InĀ [6]:
mse_column = 'mse'
# n_rounds, y = preprocessing_results(filenames=[global_FedCluLearn, global_FedCluLearn_recent, global_FedCluLearn_percentage, global_FedAvg, global_FedAtt, global_FedProx, global_FedCluLearn_Prox, global_FedCluLearn_Prox_recent, None], mse_column=mse_column)
# global_filenames = [global_FedCluLearn, global_FedAvg, global_FedAtt, global_FedProx, global_FedCluLearn_Prox]
global_filenames = [global_FedCluLearn, global_FedAvg, global_FedAtt, global_FedProx, global_FedCluLearn_Prox]
n_rounds, y = preprocessing_results(filenames=global_filenames, mse_column=mse_column)
#Avg {mse_column.upper()} Global model
plot_plotly(n_rounds, y, title=f'Global model', y_axis_title=f'{mse_column.upper()}', y_axis_max=1)
InĀ [7]:
mse_column = 'r2'
global_filenames = [global_FedCluLearn, global_FedAvg, global_FedAtt, global_FedProx, global_FedCluLearn_Prox]
n_rounds, y = preprocessing_results(filenames=global_filenames, mse_column=mse_column)
plot_plotly(n_rounds, y, title=f'Global model', y_axis_title=f'{mse_column.upper()}', y_axis_max=1)
InĀ [8]:
mse_column='mse'
for client_id in [0,1,2]:
    n_rounds, y = preprocessing_results(filenames=global_filenames, client_id=client_id,mse_column=mse_column)
    plot_plotly(n_rounds, y, title=f'Global model - test data Client {client_id}', y_axis_title=f'{mse_column} error')
InĀ [9]:
mse_column='r2'
for client_id in [0,1,2]:
    n_rounds, y = preprocessing_results(filenames=global_filenames, client_id=client_id,mse_column=mse_column)
    plot_plotly(n_rounds, y, title=f'Global model - test data Client {client_id}', y_axis_title=f'{mse_column} error')
InĀ [10]:
mse_column='mse'
for client_id in [0,1,2]:
    n_rounds, y = preprocessing_results(filenames=[local_FedCluLearn, global_FedCluLearn, None, None, None], client_id=client_id,mse_column=mse_column)
    plot_plotly(n_rounds, y, title=f'Local vs Global Client {client_id}', y_axis_title=f'{mse_column} error', algo_name1='Local FedCluLearn', algo_name4='Global FedCluLearn')
InĀ [11]:
mse_column = 'mse'
# n_rounds, y = preprocessing_results(filenames=[global_FedCluLearn, global_FedCluLearn_recent, global_FedCluLearn_percentage, global_FedAvg, global_FedAtt, global_FedProx, global_FedCluLearn_Prox, global_FedCluLearn_Prox_recent, None], mse_column=mse_column)
global_filenames = [None, None, global_FedCluLearn_percentage, global_FedAvg, global_FedAtt, global_FedProx, None, None, global_FedCluLearn_Prox_percentage, None, None, None, None]
# global_filenames = [None, None, None, global_FedAvg, global_FedAtt, global_FedProx, None, None, None, global_FedCluLearn_percentage_25, None, global_FedCluLearn_Prox_percentage_25, None]
n_rounds, y = preprocessing_results(filenames=global_filenames, mse_column=mse_column)
plot_plotly_real(n_rounds, y, title=f'', y_axis_title=f'{mse_column.upper()} error', y_axis_max=1, name='real_mse_air_all_5_parts', algo_name3='FedCluLearn-50%', algo_name9='FedCluLearn-Prox-50%')  #Avg {mse_column.upper()} Global model
InĀ [12]:
mse_column = 'mse'
# n_rounds, y = preprocessing_results(filenames=[global_FedCluLearn, global_FedCluLearn_recent, global_FedCluLearn_percentage, global_FedAvg, global_FedAtt, global_FedProx, global_FedCluLearn_Prox, global_FedCluLearn_Prox_recent, None], mse_column=mse_column)
global_filenames = [global_FedCluLearn, global_FedCluLearn_recent, global_FedCluLearn_percentage, None, None, None, None, None, None, global_FedCluLearn_percentage_25, global_FedCluLearn_percentage_75, None, None]
n_rounds, y = preprocessing_results(filenames=global_filenames, mse_column=mse_column)
plot_plotly_real(n_rounds, y, title=f'Global model FedCluLearn', y_axis_title=f'{mse_column.upper()} error', y_axis_max=1, name='real_mse_air_fedclulearn_5_parts')  # Avg {mse_column.upper()} Global model
InĀ [13]:
mse_column = 'mse'
# n_rounds, y = preprocessing_results(filenames=[global_FedCluLearn, global_FedCluLearn_recent, global_FedCluLearn_percentage, global_FedAvg, global_FedAtt, global_FedProx, global_FedCluLearn_Prox, global_FedCluLearn_Prox_recent, None], mse_column=mse_column)
global_filenames = [None, None, None, None, None, None, global_FedCluLearn_Prox, global_FedCluLearn_Prox_recent, global_FedCluLearn_Prox_percentage, None, None, global_FedCluLearn_Prox_percentage_25, global_FedCluLearn_Prox_percentage_75]
n_rounds, y = preprocessing_results(filenames=global_filenames, mse_column=mse_column)
plot_plotly_real(n_rounds, y, title=f'Global model FedCluLearn-Prox', y_axis_title=f'{mse_column.upper()} error', y_axis_max=1, name='real_mse_air_fedclulearn_prox_5_parts')  # Avg {mse_column.upper()} Global model